package com.ceba.test.modules.cnca;

import com.ceba.test.base.enums.CncaReturnCodeEnum;

import java.util.Date;
import java.util.List;

/**
 * Created by liguangyao on 3/8/2020.
 */
public class UploadReportResponse {
    //返回代码
    private CncaReturnCodeEnum renCode;
    //返回描述
    private String renDesc;
    //时间戳。日期yyyy-MM-dd HH:mm:ss的字符串
    private Date timeStamp;
    //保存成功的数据条数
    private int successCount;
    //保存失败的数据条数
    private int failCount;
    //保存失败的数据列表
    private List<CncaFailList> failList;


    public String getFailListString(int showLimit) {
        if (showLimit > CncaFailList.MAX_FAIL_COUNT)
            showLimit = CncaFailList.MAX_FAIL_COUNT;
        else if(showLimit < 1)
            showLimit = 1;

        StringBuilder sb = new StringBuilder();
        int cnt = 0;
        for (CncaFailList failItem : failList) {
            if (++cnt == showLimit)
                break;

            sb.append(failItem.getFailCode());
            sb.append(":");
            sb.append(failItem.getFailDetail());
            sb.append("\n");
        }
        return sb.toString();
    }

    public CncaReturnCodeEnum getRenCode() {
        return renCode;
    }

    public void setRenCode(CncaReturnCodeEnum renCode) {
        this.renCode = renCode;
    }

    public String getRenDesc() {
        return renDesc;
    }

    public void setRenDesc(String renDesc) {
        this.renDesc = renDesc;
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
    }

    public int getSuccessCount() {
        return successCount;
    }

    public void setSuccessCount(int successCount) {
        this.successCount = successCount;
    }

    public int getFailCount() {
        return failCount;
    }

    public void setFailCount(int failCount) {
        this.failCount = failCount;
    }

    public List<CncaFailList> getFailList() {
        return failList;
    }

    public void setFailList(List<CncaFailList> failList) {
        this.failList = failList;
    }
}
